#ifndef SCRIPT_LEXER_H
#define SCRIPT_LEXER_H

#include <optional>
#include <global.h>
#include <scripting/script_header.h>

namespace script
{
class ScriptLexerData;

/**
 * @brief:  词法分析器
 * @author: sherlock_lht
 */
class ScriptLexer
{
public:
    explicit ScriptLexer();
    ~ScriptLexer();

    /**
     * @brief:  扫描代码，分析此法，返回token
     * @author: sherlock_lht
     */
    std::optional<script::Tokens> scan(const std::string &code);

    /**
     * @brief:  解析失败获取错误代码行号和错误描述
     * @note:   如果未解析失败，则获取的line_number为0,error_msg为空
     * @author: sherlock_lht
     */
    void getErrorInfo(int *line, int *column, std::string *error_msg) const;

private:
    DECLARE_DATA(ScriptLexer)
};

}


#endif //SCRIPT_LEXER_H
